//
//  OrdinaryUserMainViewController.m
//  EPBPro
//
//  Created by wucha on 2018/6/16.
//  Copyright © 2018年 fc. All rights reserved.
//

#import "OrdinaryUserMainViewController.h"
#import "CycleScrollView.h"
#import "ResizeView.h"

@interface OrdinaryUserMainViewController ()<CycleScrollViewDelegate,CycleScrollViewDatasource>
@property (nonatomic,strong) CycleScrollView *adsCycleScrollView;

@end

@implementation OrdinaryUserMainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
//    self.tableView.hidden = YES;
    int statesHeight = 0;
    if (kDevice_Is_iPhoneX) {
        statesHeight = 44;
    }
    ResizeView *resizeView = [[ResizeView alloc] initWithFrame:CGRectMake(0, statesHeight, SCREEN_WIDTH, SCREEN_HEIGHT-TabBarHeight-statesHeight)];
    [self.view addSubview:resizeView];
    
    ResizeViewInfo *resizeInfo = [[ResizeViewInfo alloc] init];
    resizeInfo.height = ScreenScale(180);
    self.adsCycleScrollView = [[CycleScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScreenScale(180)) withPageControlStyle:PageControlTypeDefault withPageControlFrame:CGRectMake(0,ScreenScale(180)-20,SCREEN_WIDTH, 20) addSubViewToView:self.view];
    _adsCycleScrollView.pageControl.backgroundColor= [UIColor clearColor];
    _adsCycleScrollView.pageControl.alpha =1.0f;
    _adsCycleScrollView.delegate = self;
    _adsCycleScrollView.datasource =self;
    [resizeInfo addSubview:_adsCycleScrollView];
    [resizeView addResizeSubview:resizeInfo];
    [resizeView addResizeSubview:[self getEPBInfomation]];
    
    
}

-(ResizeViewInfo*)getHeaderResizeViewInfo{
    ResizeViewInfo *resizeInfo = [[ResizeViewInfo alloc] init];
    resizeInfo.view.backgroundColor = [UIColor blueColor];
    resizeInfo.height = 20;
    
    return resizeInfo;
}

-(ResizeViewInfo*)getEPBInfomation{
    ResizeViewInfo *resizeInfo = [[ResizeViewInfo alloc] init];
    resizeInfo.height = 100;
    resizeInfo.view.backgroundColor = HexRGB(0xF59231);
    
    NSArray *array = @[@"广告收益费用\n\n4000万元",@"总机位数\n\n20w台",@"投放城市数\n\n20个"];
    for (int i =0; i<array.count; i++) {
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(i*SCREEN_WIDTH/3, 0, SCREEN_WIDTH/3, 100)];
        label.numberOfLines = 0;
        label.font = [UIFont systemFontOfSize:12];
        label.textColor = [UIColor whiteColor];
        label.textAlignment = NSTextAlignmentCenter;
        label.text = array[i];
        [resizeInfo addSubview:label];
    }
    
    return resizeInfo;
}

#pragma mark-CycleScrollViewDelegate
- (NSInteger)numberOfPagesAt:(CycleScrollView *) csView{
    return 4;
}

- (UIView *) cycleScrollView:(CycleScrollView *) csView pageAtIndex:(NSInteger)index{
//    ImageObject *imageObject = self.listArray[index];
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, ScreenScale(180))];
    view.backgroundColor = randomColor;
//    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
//    button.frame = view.bounds;
//    [view addSubview:button];
//    [button sd_setBackgroundImageWithURL:[NSURL URLWithString:imageObject.imgUrl] forState:UIControlStateNormal];
    return view;
}

- (void)didClickPage:(CycleScrollView *)csView atIndex:(NSInteger)index{
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
